//
//  WBNaviViewController.swift
//  daoge_sineweibo
//
//  Created by 伍禄林 on 16/9/26.
//  Copyright © 2016年 伍禄林. All rights reserved.
//

import UIKit

class WBNaviViewController: UINavigationController {
    
    override func loadView() {
        super.loadView()
        navigationBar.isHidden = true
       
    }
    

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if(childViewControllers.count > 0) {
            viewController.hidesBottomBarWhenPushed = true
            
            if let vc = viewController as? WBBaseViewController {
             
                var title = "返回"
                
                if childViewControllers.count == 1 {
                    
                    title = vc.naviItem.title ?? "返回"
                }
                
                vc.naviItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popBack),isBack: true)
                
                
            }
        }
        
        
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func popBack () {
    
        popViewController(animated: true)
    }
}
